import React, { Component } from 'react';
import { TabBar } from 'antd-mobile';
import { withRouter } from 'react-router-dom';
import { AppOutline,AppstoreOutline,MessageOutline,ShopbagOutline,UserOutline } from 'antd-mobile-icons';

class Tabbar extends Component {
    state = {
        tabs: [
            {
                key: '/index/home',
                title: '首页',
                icon: <AppOutline />,
            },
            {
                key: '/index/cate',
                title: '分类',
                icon: <AppstoreOutline />,
            },
            {
                key: '/index/news',
                title: '消息',
                icon: <MessageOutline />,
            },
            {
                key: '/index/shopcart',
                title: '购物车',
                icon: <ShopbagOutline />,
            },
            {
                key: '/index/mine',
                title: '我的',
                icon: <UserOutline />,
            },
        ],
    }
    goChange(key){
        this.props.history.push(key)
    }
    render() {
        return (
            <div className='tabbar'>
                <TabBar onChange={(key)=>{this.goChange(key)}}>
                    {this.state.tabs.map(item => (
                        <TabBar.Item key={item.key} icon={item.icon} title={item.title} />
                    ))}
                </TabBar>
            </div>
        );
    }
}

export default withRouter(Tabbar);